package com.example.mobile2121606110syc0414;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class PeopleAdapter extends RecyclerView.Adapter<PeopleAdapter.ViewHolder> {
    String[] names;
    String[] names2;
   public PeopleAdapter(String[] names, String[] names2){
       this.names = names;
       this.names2 = names2;
   }
    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_main_people,parent,false);
        ViewHolder viewHolder = new ViewHolder(itemView);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.tvItemName2.setText(names[position]);
        holder.tvItemName.setText(names2[position]);

    }

    @Override
    public int getItemCount() {
        return names.length;
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvItemName;
        TextView tvItemName2;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvItemName =itemView.findViewById(R.id.tvitemName);
            tvItemName2 = itemView.findViewById(R.id.tvitemName2);
        }
    }
}